/***2024-12-19 迷途小羔羊
* 用于编写mmo战斗AI逻辑
*/
namespace ghost
{
    export class MMOSmart extends AIBase
    {	
		/**上次执行智能的时间*/protected _smartTime:number;
		/**巡逻时索敌的时间间隔*/public static NEW_HANG_PATROLENEMY_INTERVAL:number = 500;
        constructor(data:ISmartParam)
        {
            super(data);			
        }
		protected behaviorInit():void{
			let s = this;
			s.addBehaviors([BehaviorEnum.ATTACK,BehaviorEnum.DETOUR]);			
		}
        /**重置状态*/
        protected resetMMOSmartState():void
		{
			let r:GameRole;
            r = this._data.role;
			r.setAtkTarget(null);
			// r.hateList = null;
			// r.inRangeFlag = 1;
			// r.isDetachmentFromWar = false;
			// r.inResourceState = r.inBattleState = false;
			// r.hasResourceInRange = false;//脱战重置下	
			r.setHasEnemyInRange(false);
		}
			
		/**怪物的新挂机智能*/
		public smart(t:number):void
		{            
			let s = this;
            let r:GameRole = s._data.role;
			if(r._isDead)return;
			if(r.inAirPos)return;
			// if(r._scene.hangupSmartPaused)return;
			//脱离智能时间超过5秒，重置前置cd
			// if(t - s._smartTime > 5000)
			// {
			// 	r.resetPreCD(t);
			// }			
			s._smartTime = t;	
			if(r.sts > StsType.RUN)// || BuffLogic.hasBuffLimit(r))
				return;
			super.smart(t);
			if(s._behaviorType > -1)return;			
			// s.setBehavior(r.canPatrol?BehaviorEnum.PATROL:BehaviorEnum.ATTACK);
			s.setBehavior(BehaviorEnum.ATTACK);
		}    
		public behaviorOut(b: BehaviorBase, nextBehavior: BehaviorEnum): void 
		{
			super.behaviorOut(b, nextBehavior);
			let s = this;
			if(nextBehavior == BehaviorEnum.ATTACK)
				s.resetMMOSmartState();
			s.setBehavior(nextBehavior);
		}
        public targetChange(): void
        {   
            let s = this;
            super.targetChange();
			if(s._behaviorType == BehaviorEnum.DETOUR)
            	(<B_Detour>s._behavior).detourClockwise = NaN;
        }
        public outSmart(): void {
            super.outSmart();
            this.resetMMOSmartState();
        }
    }
}